When creating a user via the API, the ‘role’ attribute must be one of (from the error message):
Role must be in read_only_user, owner, admin, user, observer, limited_user, team_responder, or restricted_access.
If ‘team_responder’ is picked, the user is created with a base role of ‘observer’. When that user is added to a team they have the team role of ‘observer’.
The ‘role’ attribute does work correctly when setting the role to ‘user’ (aka manager).
Example code:
import json
import os
import pypd
user_data = {
"type": "user",
"name": "New User",
"email": "new@example.com",
"role": "team_responder",
}
print("User to create:")
print(json.dumps(user_data, indent=2, sort_keys=True))
user = pypd.User.create(
data=user_data,
from_email="me@example.com",
api_key=os.environ["PAGERDUTY_API_KEY"],
)
print("\nUser created:")
print(json.dumps(user.json, indent=2, sort_keys=True))
I’ve tried it with the Python and Go libraries, same behavior.
How do I create users with the role of ‘team_responder’ or ‘responder’[1] via the API?
[1] ‘responder’ isn’t accepted by API when creating a user.